# Merge init into the mk_disklessinit template.
#
# $Id: Makefile 3 2008-02-18 22:49:14Z efocht $

NAME ?= diskless_cluster_framework

all: mk_disklessinit

mk_disklessinit: mk_disklessinit.in diskless.init
	@perl -e 'while(<STDIN>){if(/INIT_PLACEHOLDER/){open IN,"diskless.init";while($$l=<IN>){print "\t$$l";}close IN;}else{print $$_;}}' < $< > $@ && \
	echo "Inserted init into $@" && \
	chmod 755 $@ && \
	echo "Built $@"

clean:
	rm -f mk_disklessinit

install: all
	install -m 755 -d $(DESTDIR)/usr/share/$(NAME)/examples
	install -m 644 sample/* $(DESTDIR)/usr/share/$(NAME)/examples
	install -m 644 README.diskless-imager $(DESTDIR)/usr/share/$(NAME)/
	install -m 755 -d $(DESTDIR)/usr/bin
	install -m 755 mk_disklessinit $(DESTDIR)/usr/bin
